import React from "react";
// 导入withRouter高阶组件
import { withRouter } from 'react-router-dom'
// 导入props效验
// import PropTypes from 'prop-types'
import propTypes from 'prop-types'
import './index.scss'

function NavHeader({ title, history, onLeftClick }) {
  const dfaultHanden = () => { history.go(-1) }
  console.log(history)
  return (
    <div className="cityList1">
      <div className="navbar1">
        <div className="left1" onClick={dfaultHanden || onLeftClick}><i className="iconfont icon-cangku"></i></div><div className="con1">{title}</div><div className="right1"></div>
      </div>
    </div>
  )
}

// tianjian 添加proptyps效验
// NavHeader.PropTypes = {
//   title: PropTypes.string.isRequired,//isRequired是必填项
//   onLeftClick: PropTypes.func,
// }
NavHeader.propTypes = {
  title: propTypes.string.isRequired,
  onLeftClick: propTypes.func
}

export default withRouter(NavHeader)